/**
 * @author gao
 * @date  2025/6/24 22:14
 */

public class Demo7 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> {
            for (int i = 0; i < 5; i++) {
                System.out.println("hello thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    break;
                }
            }
        });
        t.start();

        System.out.println("等待之前");
        // 等3秒之后就不等了
        t.join(3000);
        System.out.println("等待之后");
    }
}